package main.db;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;



public class ColumnUtils {
	private static String tableName = "users";
	
	public static void main(String[] args) {
		try {
			String colstring = ColumnUtils.getColumns(tableName);
			System.out.println(colstring);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static String getColumns(String table) throws SQLException{
		
		StringBuffer cols = new StringBuffer();
		Connection conn = null;
		try {
			conn = BeanBuilder.getConnection();
			List<Col> colList = BeanBuilder.cols(conn, table);
			int i = 0;
			for(Col col:colList){
				cols.append(col.getColName());
				if(++i<colList.size()){
					cols.append(",");
				}
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			conn.close();
		}		
		return cols.toString();
	}

}
